//
//  AquaButton.m
//  sortuviphonelib
//
//  Created by Jim Heising on 3/8/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "AquaButton.h"
#import "DrawingUtilities.h"

@implementation AquaButton
@synthesize bgColor;
@synthesize hiliteColor;
@synthesize borderColor;
@synthesize roundedHilite;
@synthesize borderWidth;
@synthesize drawShadow;
@synthesize shadowSize;

-(void)awakeFromNib
{
	[self initView];
}

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}

-(void)initView
{
	self.drawShadow = NO;
	self.shadowSize = 20;
	self.roundedHilite = YES;
	self.borderWidth = 2.0;
	self.hiliteColor = [UIColor colorWithWhite:1.0 alpha:0.5];
	self.borderColor = [UIColor colorWithWhite:0.60 alpha:1.0];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
	touchDown = YES;
	[super touchesBegan:touches withEvent:event];
	[self setNeedsDisplay];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
	touchDown = NO;
	[super touchesCancelled:touches withEvent:event];
	[self setNeedsDisplay];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
	touchDown = NO;
	[super touchesEnded:touches withEvent:event];
	[self setNeedsDisplay];
}

-(void)setBackgroundColor:(UIColor*)color
{
	super.backgroundColor = [UIColor clearColor];
	self.bgColor = color;
}

- (void)drawRect:(CGRect)rect {
	
	CGContextRef context = UIGraphicsGetCurrentContext();
	
	[DrawingUtilities drawAquaView:context :rect :self.bgColor :self.hiliteColor :self.borderColor :self.borderWidth :7 :0.5 :self.roundedHilite :touchDown];
	
	return;
}


- (void)dealloc {
	[hiliteColor release];
	[borderColor release];
	[bgColor release];
    [super dealloc];
}


@end
